package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class LoginController {

    @Autowired
    private EmpService empService;

    @PostMapping("/login")
    public Result login(@RequestBody Emp emp) {
     LoginInfo loginInfo =  empService.login(emp);
     if(loginInfo != null) {
         //有该用户
         return Result.success(loginInfo);
     }
     //没有该用户
     return Result.error("您输入的信息有误");
    }
    //日志信息的分页查询
    @GetMapping("/log/page")
    public Result getLog(
          @RequestParam(defaultValue = "1")  Integer page,
          @RequestParam(defaultValue = "10") Integer pageSize){
    PageResult<OperateLog> pageResult = empService.getLog(page , pageSize);
    return Result.success(pageResult);
    }
}
